#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_INIT(iptux, 0.5.3, jallyx@gmail.com)
#AM_MAINTAINER_MODE
AC_CONFIG_SRCDIR(config.h.in)
AC_CONFIG_HEADERS(config.h)
AM_INIT_AUTOMAKE(foreign dist-bzip2 -Wall)

# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB

# Checks for libraries.

# Checks for header files.
AC_CHECK_HEADERS(arpa/inet.h fcntl.h inttypes.h libintl.h locale.h \
                 netinet/in.h stdint.h stdlib.h string.h strings.h \
                 sys/ioctl.h sys/socket.h sys/time.h sys/vfs.h unistd.h)

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_INT64_T
AC_TYPE_MODE_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T

# Checks for library functions.
AC_FUNC_FORK
AC_CHECK_FUNCS(bzero endpwent getcwd gettimeofday inet_ntoa memchr memmove \
               mkdir rmdir setlocale socket strcasecmp strchr strerror \
               strncasecmp strpbrk strrchr strspn)

AC_DEFINE(__IP_TUX__, 1, [Define if you want to use defined macros for iptux.])
AC_ARG_ENABLE([message],
              AS_HELP_STRING([--disable-message],
                             [disable print message @<:@default=yes@:>@]),
              [enable_message=$enableval],
              [enable_message=yes])
if test "x${enable_message}" = "xyes" ; then
  AC_DEFINE(MESSAGE, 1, [Define if you want to print message])
fi
AC_ARG_ENABLE([warning],
              AS_HELP_STRING([--disable-warning],
                             [disable print warning @<:@default=yes@:>@]),
              [enable_warning=$enableval],
              [enable_warning=yes])
if test "x${enable_warning}" = "xyes" ; then
  AC_DEFINE(WARNING, 1, [Define if you want to print warning])
fi
AC_ARG_ENABLE([trace],
              AS_HELP_STRING([--enable-trace],
                             [enable print trace @<:@default=no@:>@]),
              [enable_trace=$enableval],
              [enable_trace=no])
if test "x${enable_trace}" = "xyes" ; then
  AC_DEFINE(TRACE, 1, [Define if you want to print trace])
fi

dnl In Autoconf 2.63, ${bindir} --> ${exec_prefix}
dnl In Autoconf 2.63, ${datadir} --> ${datarootdir} --> ${prefix}
test "x${prefix}" = xNONE && prefix="${ac_default_prefix}"
test "x${exec_prefix}" = xNONE && exec_prefix="${prefix}"
tmpdir=`eval echo ${bindir}`
AC_DEFINE_UNQUOTED(__EXEC_PATH, "${tmpdir}", [System Execute Directory])
tmpdir=`eval echo ${datadir}`
tmpdir=`eval echo ${tmpdir}`
AC_DEFINE_UNQUOTED(__DATA_PATH, "${tmpdir}", [System Data Directory])
localedir="${tmpdir}/locale"
AC_DEFINE_UNQUOTED(__LOCALE_PATH, "${localedir}", [System Locale Directory])
desktopdir="${tmpdir}/applications"
AC_DEFINE_UNQUOTED(__DESKTOP_PATH, "${desktopdir}", [System Applications Directory])
AC_SUBST(desktopdir)
logodir="${tmpdir}/icons"
AC_DEFINE_UNQUOTED(__LOGO_PATH, "${logodir}", [Iptux Logo Directory])
AC_SUBST(logodir)
pixmapsdir="${tmpdir}/iptux/pixmaps"
AC_DEFINE_UNQUOTED(__PIXMAPS_PATH, "${pixmapsdir}", [Iptux Pixmaps Directory])
AC_SUBST(pixmapsdir)
sounddir="${tmpdir}/iptux/sound"
AC_DEFINE_UNQUOTED(__SOUND_PATH, "${sounddir}", [Iptux Sound Directory])
AC_SUBST(sounddir)

glib_modules="glib-2.0 >= 2.16.0"
PKG_CHECK_MODULES(GLIB, [$glib_modules])
gthread_modules="gthread-2.0 >= 2.14.0"
PKG_CHECK_MODULES(GTHREAD, [$gthread_modules])
gtk_modules="gtk+-2.0 >= 2.12.0"
PKG_CHECK_MODULES(GTK, [$gtk_modules])
gio_modules="gio-2.0 >= 2.26.0"
PKG_CHECK_MODULES(GIO, [$gio_modules])
gst_modules="gstreamer-0.10 >= 0.10.0"
PKG_CHECK_MODULES(GST, [$gst_modules], have_gst=yes, have_gst=no)
if test "${have_gst}" = yes ; then
AC_DEFINE(HAVE_GST, 1, [Define if you system has installed gstreamer already])
else
AC_MSG_WARN(You need GStreamer-0.10 or later installed if you need sound relevant functions)
fi
PACKAGE_CFLAGS="${GLIB_CFLAGS} ${GTHREAD_CFLAGS} ${GTK_CFLAGS} ${GIO_CFLAGS} ${GST_CFLAGS}"
PACKAGE_LIBS="${GLIB_LIBS} ${GTHREAD_LIBS} ${GTK_LIBS} ${GIO_LIBS} ${GST_LIBS}"
AC_SUBST(PACKAGE_CFLAGS)
AC_SUBST(PACKAGE_LIBS)

GETTEXT_PACKAGE=iptux
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "${GETTEXT_PACKAGE}", [Gettext Package])

dnl Add the languages which your application supports here.
ALL_LINGUAS="de en_GB es pl zh_CN zh_TW"
AM_GLIB_GNU_GETTEXT

dnl Add gsettings rules
GLIB_GSETTINGS

AC_OUTPUT(Makefile desktop/Makefile pixmaps/Makefile po/Makefile.in sound/Makefile \
	src/Makefile src/uninstall/Makefile)
